//获取需处理的DOM元素节点
const todoList = document.querySelector("ul");
const input = document.querySelector("input");
const button = document.querySelector("button");

//增加单击事件处理
button.addEventListener("click", () => {
    const myItem = input.value;  //获取input输入框中的值
    input.value = "";

    const listItem = document.createElement("li");
    const listText = document.createElement("span");
    const listBtn = document.createElement("button");
    listText.textContent = myItem;
    listItem.appendChild(listText);

    listBtn.textContent = "删除";
    listItem.appendChild(listBtn);
    listBtn.addEventListener("click", () => {
        // todoList.removeChild(listItem);
        //通过内联样式（style属性）增加删除线
        listItem.style.textDecoration = "line-through"
        input.focus();
    })

    todoList.append(listItem);
    
    input.focus();
})